/*
 * JOGRE (Java Online Gaming Real-time Engine) - TicTacToe
 * Copyright (C) 2004  Bob Marks (marksie531@yahoo.com)
 * http://jogre.sourceforge.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.jogre.mayi.common;

import nanoxml.XMLElement;

import org.jogre.common.comm.CommTableMessage;

/**
 * Communications object for transmitting a card for spades.
 *
 * @author Garrett Lehman (Gman)
 * @version Alpha 0.2.3
 */
public class CommMayIDrawCard extends CommTableMessage {

	// xml information
	public static final String XML_NAME = "mayi_draw_card";
	public static final String ATT_TYPE = "type";
	public static final String ATT_DRAW_USER = "drawUser";
	
	public static final int FROM_DECK = 0;
	public static final int FROM_DISCARD = 1;
	public static final int MAY_I = 2;

	private int type = -1;
	private String drawUser = null;
	

	/**
	 * Constructor that takes a username and card object.
	 *
	 * @param username
	 *            Username
	 * @param card
	 *            Card
	 */
	public CommMayIDrawCard(String username, int type) {
		super(username);
		this.type = type;
		this.drawUser = username;
	}

	/**
	 * Constuctor that takes an xml element and creates an object from that xml
	 * element.
	 *
	 * @param message
	 *            Xml element
	 */
	public CommMayIDrawCard(XMLElement message) {
		super(message);

		this.type = message.getIntAttribute(ATT_TYPE);
		this.drawUser = message.getAttribute(ATT_DRAW_USER).toString();
	}

	

	

	public String getDrawUser() {
		return drawUser;
	}

	public void setDrawUser(String drawUser) {
		this.drawUser = drawUser;
	}

	public int getType() {
		return type;
	}

	/**
	 * Flattens this object into xml.
	 *
	 * @see org.jogre.common.comm.ITransmittable#flatten()
	 */
	public XMLElement flatten() {
		XMLElement message = super.flatten(XML_NAME);
		message.setIntAttribute(ATT_TYPE, this.type);
		message.setAttribute(ATT_DRAW_USER, this.drawUser);
		return message;
	}
}